<#-- 评论列表  分页 -->
<#-- 本样式要引入 jquery.min.js   kindeditor  layer -->
<#--可接收参数 topicId:话题Id  commentId:评论Id  page:分页-->
<@function topicId="${url_topicId}" commentId="${url_commentId}" page="${url_page}" >
<#assign pageView =  topicRelated_comment_page> 

<#if pageView.records?exists && topicRelated_comment_page.records?size gt 0> 
	
	<div class="commentModule" >
		<ol class="commentList">
			<!-- #comment-## -->
			<#list pageView.records as comment>
				<div class="commentInfo" id="anchor_${comment.id}">
					<div class="comment-author">
						<a href="user/control/home?userName=${comment.userName}">
						<#if comment.avatarName != null>
							<img src="${comment.avatarPath}100x100/${comment.avatarName}" >
						<#else>
							<!--[if (IE)]><img src="${commonPath}images/min_avata.png"><![endif]-->
							<!--[if !(IE)]><!--><img avatar="${(comment.nickname != null && comment.nickname??) ?string(comment.nickname , comment.userName)}" ><!--<![endif]-->
						</#if> 
						<cite>
							<a href="user/control/home?userName=${comment.userName}">
								${(comment.nickname != null && comment.nickname??) ?string(comment.nickname , comment.userName)}
							</a>
							<#list comment.userRoleNameList as roleName>
								<span class="userRoleName">${roleName}</span>
										
							</#list>
							<#if comment.isStaff>
								<span class="staff">官方人员</span>
							</#if>
							<#if comment.userName == topic.userName && comment.isStaff == topic.isStaff>
								<span class="master">作者</span>
							</#if>
							
						</cite> 
					</div>
					<div class="commentTime">${comment.postTime}</div>
					<#if comment.quoteList?? && comment.quoteList?size gt 0> 
					<div class="quote">
						<#assign quoteContent = ""> 
						<#list comment.quoteList as quote>
							<#assign avatarHtml = "<a class='avatarBox' href='user/control/home?userName="+quote.userName+"'>"+(quote.avatarName != null && quote.avatarName??) ?string("<img src='"+quote.avatarPath+"100x100/"+quote.avatarName+"'>" , "<img avatar='"+(quote.nickname != null && quote.nickname??) ?string(quote.nickname , quote.userName)+"'>")+"</a>"> 
							<#assign quoteContent = "<div class='quoteComment'>"+quoteContent+"<span class='userName'>"+avatarHtml+"<a href='user/control/home?userName="+quote.userName+"'>"+(quote.nickname != null && quote.nickname??) ?string(quote.nickname , quote.userName)+"</a>"+"&nbsp;的评论：</span><br/>"+quote.content+"</div>"> 
						</#list>
						<#noescape>${quoteContent}</#noescape>
					</div>
					</#if> 
					<div class="commentContent"><#noescape>${comment.content}</#noescape></div>
					<div class="clearfix"></div>
					<#if comment.totalReply gt 0> 
						<div class="replyList">
							<ul class="box">
								<#list comment.replyList as reply>
									<li>
										
								        <div class="reply-top" >
									    	<a class="avatarBox" href="user/control/home?userName=${reply.userName}">
												<#if reply.avatarName != null>
													<img src="${reply.avatarPath}100x100/${reply.avatarName}" >
												<#else>
													<!--[if (IE)]><img src="${commonPath}images/min_avata.png"><![endif]-->
													<!--[if !(IE)]><!--><img avatar="${(reply.nickname != null && reply.nickname??) ?string(reply.nickname , reply.userName)}" ><!--<![endif]-->
												</#if> 
											</a>
									    	<a class="userName" href="user/control/home?userName=${reply.userName}">
												${(reply.nickname != null && reply.nickname??) ?string(reply.nickname , reply.userName)}
											</a>
											
											<#if reply.userRoleNameList?size gt 0>
												<div class="userTag">
													<#list reply.userRoleNameList as roleName>
														<span class="userRoleName">${roleName}</span>
													</#list>
												</div>
											</#if> 
											<#if reply.isStaff>
												<div class="userTag">
										        	<span class="staff">官方人员</span>
									        	</div>
											</#if>
											<#if reply.userName == topic.userName && reply.isStaff == topic.isStaff>
												<div class="userTag">
													<span class="master">作者</span>
												</div>
											</#if>
											<span class="time">
												<#if systemUser != null && reply.userName ==  systemUser.userName>
													<a href="javascript:" onclick="editReplyLayer('${reply.id}','${(reply.nickname != null && reply.nickname??) ?string(reply.nickname , reply.userName)}');">编辑</a>&nbsp;
												</#if>
												${reply.postTime}
											</span>
										</div>
										<div style="clear:both; height: 0; line-height: 0; font-size: 0;"></div>
										<div id="editCommentReply-replyContent_${reply.id}" class="replyContent">${reply.content}</div>
										<div id="editCommentReply-post_${reply.id}" ></div>
									</li>
								</#list>
							</ul>
						</div> 
					</#if> 
					<div id="commentReply-post_${comment.id}" class="commentReply-post">
					
					</div>
					<div id="quote-post_${comment.id}" class="quote-post">
					
					</div>
					<div id="editComment-post_${comment.id}" class="editComment-post">
					
					</div>
					<div class="tipBottom">
						<span class="a-toolbar">
							<#if systemUser != null && comment.userName ==  systemUser.userName>
								<a href="javascript:" onclick="editCommentLayer('${comment.id}','${(comment.nickname != null && comment.nickname??) ?string(comment.nickname , comment.userName)}');">编辑</a>&nbsp;|
							</#if>
							<a href="javascript:" onclick="replyLayer('${comment.id}','${(comment.nickname != null && comment.nickname??) ?string(comment.nickname , comment.userName)}');">回复</a>&nbsp;|

							<a href="javascript:" onclick="quoteLayer('${comment.id}','${(comment.nickname != null && comment.nickname??) ?string(comment.nickname , comment.userName)}')">引用</a>
							<!-- 是否登录 -->
							<input type="hidden" id="isLogin" value="<#if systemUser != null>true<#else>false</#if>">
							
							
						</span>
					</div>
				</div>
			</#list>
		</ol>
		<div class="commentPage">
		   	<#-- 分页 公共页(生成新引用页)-->
			<@include action="${newPublic_1}"/>
		</div>
	</div>
</#if>	
</@function>



<script type="text/javascript">


//滚动到描点(当上级跳转来后台'我的评论' '我的回复'时)
$(function() {
	var commentId = getUrlParam("commentId");//URL中的评论Id
	if(commentId != null && commentId != ""){
		var anchor = $("#anchor_" + commentId); //获得锚点   
		
	    if (anchor.length > 0) {//判断对象是否存在   
	        var pos = anchor.offset().top;  
	      //  var poshigh = anchor.height();  
	        $("html,body").animate({ scrollTop: pos }, 500);  
	    }
	}
     
 });  


//回复展开层
function replyLayer(commentId,userName){
	//判断是否已登录
	var isLogin = document.getElementById("isLogin").value;
	if(isLogin == "false"){
		layer.open({
		    type: 1, 
		    title:"提示",
		    content: "<div style='line-height: 36px; font-size: 15px;text-align:center; margin-left: 8px;margin-right: 8px;'>请先登录</div>", 
		    area: ['260px', '120px'],//宽高
			success: function(layero, index){
				 
			}
		});
		return false;
	}
	
	var parameter = "";//URI参数
	parameter += "commentId="+commentId;
	
	
	//回复页面
	get_request(function(value){
		if(value != ""){
			$("#commentReply-post_"+commentId).html(value);
		}
	},
	getBasePath()+"comment_reply.htm?"+parameter+"&timestamp=" + new Date().getTime(), true);
	
}
function cancelReply(commentId){
	$("#commentReply-post_"+commentId).html("");
}

//修改回复展开层
function editReplyLayer(replyId,userName){
	//判断是否已登录
	var isLogin = document.getElementById("isLogin").value;
	if(isLogin == "false"){
		layer.open({
		    type: 1, 
		    title:"提示",
		    content: "<div style='line-height: 36px; font-size: 15px;text-align:center; margin-left: 8px;margin-right: 8px;'>请先登录</div>", 
		    area: ['260px', '120px'],//宽高
			success: function(layero, index){
				 
			}
		});
		return false;
	}
	
	$("#editCommentReply-replyContent_"+replyId).hide();
	$("#editCommentReply-post_"+replyId).show();
	
	var parameter = "";//URI参数
	parameter += "replyId="+replyId;
	
	
	
	//回复页面
	get_request(function(value){
		if(value != ""){
			$("#editCommentReply-post_"+replyId).html(value);
		}
	},
	getBasePath()+"user/editCommentReply?"+parameter+"&timestamp=" + new Date().getTime(), true);
	
}
function cancelEditReply(replyId){
	$("#editCommentReply-replyContent_"+replyId).show();
	$("#editCommentReply-editContent_"+replyId).hide();
	$("#editCommentReply-post_"+replyId).html("");
}


//引用弹出层
function quoteLayer(commentId,userName){
	//判断是否已登录
	var isLogin = document.getElementById("isLogin").value;
	if(isLogin == "false"){
		layer.open({
		    type: 1, 
		    title:"提示",
		    content: "<div style='line-height: 36px; font-size: 15px;text-align:center; margin-left: 8px;margin-right: 8px;'>请先登录</div>", 
		    area: ['260px', '120px'],//宽高
			success: function(layero, index){
				 
			}
		});
		return false;
	}
	
	var parameter = "";//URI参数
	parameter += "commentId="+commentId;
	
	
	//引用页面
	get_request(function(value){
		if(value != ""){
			$("#quote-post_"+commentId).html(value);
		}
	},
	getBasePath()+"comment_quote.htm?"+parameter+"&timestamp=" + new Date().getTime(), true);



}
function cancelQuote(commentId){
	$("#quote-post_"+commentId).html("");
}


//修改评论弹出层
function editCommentLayer(commentId,userName){
	//判断是否已登录
	var isLogin = document.getElementById("isLogin").value;
	if(isLogin == "false"){
		layer.open({
		    type: 1, 
		    title:"提示",
		    content: "<div style='line-height: 36px; font-size: 15px;text-align:center; margin-left: 8px;margin-right: 8px;'>请先登录</div>", 
		    area: ['260px', '120px'],//宽高
			success: function(layero, index){
				 
			}
		});
		return false;
	}
	
	var parameter = "";//URI参数
	parameter += "commentId="+commentId;
	
	
	//修改评论页面
	get_request(function(value){
		if(value != ""){
			$("#editComment-post_"+commentId).html(value);
		}
	},
	getBasePath()+"user/editComment.htm?"+parameter+"&timestamp=" + new Date().getTime(), true);



}
function cancelEditComment(commentId){
	$("#editComment-post_"+commentId).html("");
}
</script> 

